package com.shop2cn.app.liveseller.testcase;

import java.util.Date;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.shop2cn.app.liveseller.parameter.ModifySellerLiveBean;
import com.shop2cn.app.liveseller.parameter.CreateSellerLiveBean;
import com.shop2cn.app.liveseller.parameter.LiveDto;
import com.shop2cn.app.liveseller.service.ModifySellerLiveCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymttest.database.model.livesellerShop2cn.*;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.AuthCallServiceV2;
import com.ymttest.business.service.LiveRoomShop2cnCallService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.sqlwapper.livesellerShop2cn.LiveRoomShop2cnWapper;
import com.ymttest.utils.DesUtil;
import com.ymttest.utils.EnvSetup;
import com.ymttest.utils.TestDataManager;
import com.ymttest.utils.YMTDateUtil;

/**
 * 创建互动直播 FreeMaker Template自动生成代码
 */
@TestSuite
public class Ts_ModifySellerLiver {
	private static ModifySellerLiveBean ModifySellerliveBean;
	private static ModifySellerLiveCall ModifySellerliveCall;
	
	private static LiveRoomShop2cnWapper liveRoomShop2nWapper;
	private static int sellerId ;
	private static String token ;
	private static int csId;
	private static String cstoken;
	@BeforeClass
	public static void setUp() throws Exception {
		Logger.createResultFile("修改互动直播");
		sellerId = GodmchManageCallService.CreateSellerMch();
		token=AuthCallServiceV2.createToken(sellerId, "app");
		csId = GodmchManageCallService.bindClientService(
				sellerId, 1);
		cstoken = AuthCallServiceV2.createToken(csId, "app");
	}

	@Before
	public void caseUp() {
		ModifySellerliveBean = new ModifySellerLiveBean();
		ModifySellerliveCall = new ModifySellerLiveCall();
		liveRoomShop2nWapper = new LiveRoomShop2cnWapper();
	}

	@AfterClass
	public static void tearDown() {
		liveRoomShop2nWapper=null;
		Logger.generateResult(ModifySellerliveCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}

	/**
	 * @param livedto 修改参数
	 * @param livebefore 修改之前数据库
	 * @throws Exception
	 */
	private void verifyDB(LiveRoom livedto, LiveRoom livebefore) throws Exception {
		Logger.comment("数据库验证");
		LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livebefore.getId());
		Logger.debug("修改后数据："+FormatUtil.beanToGSONString(dblive));
		
		//不变
		Logger.verifyEquals(livebefore.getCountryId(), dblive.getCountryId(), "验证CountryId不会发生变化");
		Logger.verifyEquals(livebefore.getGroupId(), dblive.getGroupId(), "验证GroupId不会发生改变");
		Logger.verifyEquals(livebefore.getSellerName(), dblive.getSellerName(), "验证SellerName不会发生改变");
		Logger.verifyEquals(livebefore.getStopReason(), dblive.getStopReason(), "验证StopReason不会发生改变");
		Logger.verifyEquals(livebefore.getLivePush(), dblive.getLivePush(), "验证LivePush不会发生改变");
		Logger.verifyEquals(livebefore.getPutawayCount(), dblive.getPutawayCount(), "验证PutawayCount不会发生改变");
		Logger.verifyEquals(livebefore.getLiveProductNum(), dblive.getLiveProductNum(), "验证LiveProductNum不会发生改变");
		Logger.verifyEquals(livebefore.getLiveStatus(), dblive.getLiveStatus(), "验证LiveStatus不会发生改变");
		Logger.verifyEquals(livebefore.getAction(), dblive.getAction(), "验证Action不会发生改变");
		
		//可变
		//20180507 LiveDesc可变
		
		int diff1=YMTDateUtil.diffSecond(new Date(Long.valueOf(livedto.getEndTime())),  YMTDateUtil.getDate( dblive.getEndTime(), YMTDateUtil.YMDHMSS));
//		Logger.debug(new Date(Long.valueOf(livedto.getEndTime()))+"："+YMTDateUtil.getDate( dblive.getEndTime(), YMTDateUtil.YMDHMSS)+"："+diff1);
		Logger.verifyEquals(true ,diff1<5, "验证EndTime");
		int diff2=YMTDateUtil.diffSecond(new Date(Long.valueOf(livedto.getStartTime())),  YMTDateUtil.getDate( dblive.getStartTime(), YMTDateUtil.YMDHMSS));
		Logger.verifyEquals(true ,diff2<5, "验证StartTime");
		
		Logger.verifyEquals(livedto.getLiveDesc(), dblive.getLiveDesc(), "验证LiveDesc");
		Logger.verifyEquals(livedto.getLatitude(), dblive.getLatitude(), "验证Latitude");
		Logger.verifyEquals(livedto.getLongitude(), dblive.getLongitude(), "验证Longitude");
		Logger.verifyEquals(livedto.getLiveAddress(), dblive.getLiveAddress(), "验证LiveAddress");
		Logger.verifyEquals(livedto.getLiveCover(), dblive.getLiveCover(), "验证LiveCover");
		Logger.verifyEquals(livedto.getLiveTitle(), dblive.getLiveTitle(), "验证LiveTitle");
		Logger.verifyEquals(livedto.getShoppingAddress(), dblive.getShoppingAddress(), "验证ShoppingAddress");
		Logger.verifyEquals(livedto.getPreVideoHeight(), dblive.getPreVideoHeight(), "验证PreVideoHeight");
		Logger.verifyEquals(livedto.getPreVideoLength(), dblive.getPreVideoLength(), "验证PreVideoLength");
		Logger.verifyEquals(livedto.getPreVideoPic(), dblive.getPreVideoPic(), "验证PreVideoPic");
		Logger.verifyEquals(livedto.getPreVideoWidth(), dblive.getPreVideoWidth(), "验证PreVideoWidth");
		if(livedto.getBuyerShow()!=null) {
			Logger.verifyEquals(livedto.getBuyerShow(), dblive.getBuyerShow(), "验证getBuyerShow");
		}
		//LiveInherit
		if(livedto.getLiveInherit()!=null) {
			Logger.verifyEquals(livedto.getLiveInherit(), dblive.getLiveInherit(), "验证LiveInherit");
		}
		Logger.verifyEquals(livedto.getPreVideoUrl(), dblive.getPreVideoUrl(), "验证PreVideoUrl");
		Logger.verifyNotNull(dblive.getPushUrl(), "验证PushUrl");
		String pushurl=DesUtil.decrypt(dblive.getPushUrl(),DesUtil.DES_KEY_STRING,DesUtil.DES_IVPARAMETER);
		Map mpush=FormatUtil.httpStringToMap(pushurl.split("\\?")[1]);
		String sourcepushsecret=LiveRoomShop2cnCallService.LiveAntiKey+LiveRoomShop2cnCallService.BizId+"_"+EnvSetup.getEnv().toUpperCase()+"_"+livedto.getId()+mpush.get("txTime").toString();
		String pushtxsecret=TestDataManager.getMD5(sourcepushsecret.getBytes());
		Logger.verifyEquals(mpush.get("txSecret").toString(), pushtxsecret, "验证pushtxsecret");
		//rtmp://11418.livepush.myqcloud.com/live/11418_52?txSecret=80747057322436595a4aaf0b1cb3d71a&txTime=59EAEEE1
		Logger.verifyNotNull(dblive.getPlayUrl(), "验证PlayUrl");
//		String playUrl=DesUtil.decrypt(dblive.getPlayUrl(),DesUtil.DES_KEY_STRING,DesUtil.DES_IVPARAMETER);
//		Logger.debug(playUrl);
//		Map mplay=FormatUtil.httpStringToMap(playUrl.split("\\?")[1]);
//		String playtxsecret=TestDataManager.getMD5(sourcepushsecret.getBytes());
//		Logger.verifyEquals(mplay.get("txSecret").toString(), playtxsecret, "验证pushtxsecret");
		//rtmp://11418.liveplay.myqcloud.com/live/11418_52?txSecret=80747057322436595a4aaf0b1cb3d71a&txTime=59EAEEE1
	}

	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_001() {
		Logger.start(true, "修改互动直播成功");
		try {
			
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setCountryId(0);
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			livedto.setGroupId("@TGS#" + TestDataManager.getRandomNum(8));
//			int diff1=YMTDateUtil.diffSecond(new Date(Long.valueOf(livedto.getEndTime())),  YMTDateUtil.getDate( dblive.getEndTime(), YMTDateUtil.YMDHMSS));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setLatitude("31.2929");
			livedto.setLongitude("100.4335");
			livedto.setLiveAddress("live地址");
			livedto.setLiveCover("http://img.ymatou.com/app/flag/circle/America.png");
			livedto.setLiveTitle("修改直播标题666666"+TestDataManager.getRandomNum(10));
			livedto.setShoppingAddress("ShoppingAddress");
			livedto.setPreVideoHeight(100);
			livedto.setPreVideoLength(1500);
			livedto.setPreVideoPic("http://img.ymatou.com/app/flag/circle/France.png");
			livedto.setPreVideoWidth(200);
			livedto.setPreVideoUrl("http://www.ymatou.com/PreVideoUrl");
			livedto.setSellerName("autotestsellername");
			livedto.setStopReason("结束");
			livedto.setLivePush(1);
			livedto.setPutawayCount(100);
			livedto.setLiveProductNum(200);
			livedto.setLiveDesc("mylivedesc");
			livedto.setLiveStatus(11);
			livedto.setAction(-1);
			livedto.setBuyerShow(true);
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			
			ModifySellerliveCall.setData(ModifySellerliveBean);
			String head="accesstoken="+token;Logger.debug("ymt-pars:"+ head);ModifySellerliveCall.addHeader("ymt-pars", head);ModifySellerliveCall.callService();
			Logger.verifyEquals("{}",ModifySellerliveCall.getJsonObject().toString(), "验证返回");
			// Logger.verifyEquals("200", ModifySellerliveCall.getString("code"), "验证Code");
			verifyDB(livedto,dblive);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}

	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_ModifySellerLive_002() {
		Logger.start(true, "不输入userid,对神器直播无影响");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			livedto.setUserId(null);
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			String head="accesstoken="+token;
			Logger.debug("ymt-pars:"+ head);
			ModifySellerliveCall.addHeader("ymt-pars", head);
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("{}",ModifySellerliveCall.getJsonObject().toString(), "验证返回");
//			Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("不能为空", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_ModifySellerLive_003() {
		Logger.start(true, "非当前用户编辑直播失败");
		try {
			//20180508 了解需求 官方账户可以直播卖所有买手商品 去除权限判断
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			livedto.setUserId(livedto.getUserId()+1);
			livedto.setPreVideoUrl("http://www.ymatou.com/PreVideoUrl");
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			
			 Logger.verifyEquals("201", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyEquals("您无权编辑此直播", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P3.class })
	@TestCase
	public void Tc_ModifySellerLive_004() {
		Logger.start(true, "不输入liveid失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			livedto.setId(null);
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			 Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("不能为空", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_005() {
		Logger.start(true, "开始时间早于当前时间失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(-5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("直播开始时间必须晚于当前时间", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_006() {
		Logger.start(true, "结束时间早于开始时间失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setEndTime(YMTDateUtil.getBeforeOrNextMunite(-100));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(-100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			 Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("直播结束时间必须大于开始时间", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_007() {
		Logger.start(true, "开始时间晚于30天失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(31*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(32*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			 Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("直播开始时间最多只能设置为", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_008() {
		Logger.start(true, "标题长度过小失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setLiveTitle("修改");
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			 Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("直播名称长度需在", ModifySellerliveCall.getString("Msg"), "验证Msg");
			 //直播名称长度需在4-18个汉字
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_009() {
		Logger.start(true, "标题长度大于36失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setLiveTitle("修改互动直播"+TestDataManager.getRandomNum(36));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("直播名称长度需在", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_010() {
		Logger.start(true, "直播时间大于24小时失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(10000*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("直播时间不能大于4小时", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_011() {
		Logger.start(true, "重复修改互动直播成功");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setCountryId(0);
			livedto.setEndTime(YMTDateUtil.getBeforeOrNextMunite(60*3+15));
			livedto.setGroupId("@TGS#" + TestDataManager.getRandomNum(8));
			livedto.setStartTime(YMTDateUtil.getBeforeOrNextMunite(5));
			livedto.setLatitude("31.2929");
			livedto.setLongitude("100.4335");
			livedto.setLiveAddress("live地址");
			livedto.setLiveCover("http://img.ymatou.com/app/flag/circle/America.png");
			livedto.setLiveTitle("修改直播标题"+TestDataManager.getRandomNum(10));
			livedto.setShoppingAddress("ShoppingAddress");
			livedto.setPreVideoHeight(100);
			livedto.setPreVideoLength(1500);
			livedto.setPreVideoPic("http://img.ymatou.com/app/flag/circle/France.png");
			livedto.setPreVideoWidth(200);
			livedto.setPreVideoUrl("http://www.ymatou.com/PreVideoUrl");
			livedto.setSellerName("autotestsellername");
			livedto.setStopReason("结束");
			livedto.setLivePush(1);
			livedto.setPutawayCount(100);
			livedto.setLiveProductNum(200);
			livedto.setLiveDesc("mylivedesc");
			livedto.setLiveStatus(11);
			livedto.setAction(-1);
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			ModifySellerliveCall.callService();
			// Logger.verifyEquals("200", ModifySellerliveCall.getString("code"), "验证Code");
			Logger.verifyEquals("{}",ModifySellerliveCall.getJsonObject().toString(), "验证返回");
			verifyDB(livedto,dblive);
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_012() {
		Logger.start(true, "不输入PreVideoPic失败");
		try {
			//为空不修改
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setPreVideoPic(null);
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("200", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("预告短片封面不能为空", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_013() {
		Logger.start(true, "不输入PreVideoUrl失败");
		try {
			//为空不修改
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setPreVideoUrl(null);
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("200", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("预告短片不能为空", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	@Ignore
	public void Tc_ModifySellerLive_014() {
		Logger.start(true, "不输入LiveAddress失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setLiveAddress(null);
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("直播地不能为空", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_015() {
		Logger.start(true, "不输入StartTime失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(null);
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("开始时间不能为空", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_016() {
		Logger.start(true, "不输入EndTime失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setEndTime(null);
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("结束时间不能为空", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_017() {
		Logger.start(true, "修改待开始直播失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoomShop2cnCallService.UpdateLiveTimeToStart(livedto.getId());
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(YMTDateUtil.getBeforeOrNextMunite(5));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			 Logger.verifyEquals("201", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("直播已开始，无法编辑", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_018() {
		Logger.start(true, "修改status7关闭状态修改直播失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			liveRoomShop2nWapper.updateLiveRoomPushStatus(livedto.getId(), 7);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(YMTDateUtil.getBeforeOrNextMunite(5));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			 Logger.verifyEquals("201", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("该场直播状态已发生改变，无法进行编辑", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_019() {
		Logger.start(true, "修改status8关闭状态修改直播失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			liveRoomShop2nWapper.updateLiveRoomPushStatus(livedto.getId(), 8);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(YMTDateUtil.getBeforeOrNextMunite(5));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			 Logger.verifyEquals("201", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("该场直播状态已发生改变，无法进行编辑", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_020() {
		Logger.start(true, "修改status9关闭状态修改直播失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			liveRoomShop2nWapper.updateLiveRoomPushStatus(livedto.getId(), 9);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(YMTDateUtil.getBeforeOrNextMunite(5));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			 Logger.verifyEquals("201", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("该场直播状态已发生改变，无法进行编辑", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_021() {
		Logger.start(true, "修改status10关闭状态修改直播失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			liveRoomShop2nWapper.updateLiveRoomPushStatus(livedto.getId(), 10);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setStartTime(YMTDateUtil.getBeforeOrNextMunite(5));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			
			 Logger.verifyEquals("201", ModifySellerliveCall.getString("code"), "验证Code");
			// Logger.verifyIsContains("该场直播状态已发生改变，无法进行编辑", ModifySellerliveCall.getString("Msg"), "验证Msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_022() {
		Logger.start(true, "客服修改互动直播失败");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setCountryId(0);
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			livedto.setGroupId("@TGS#" + TestDataManager.getRandomNum(8));
//			int diff1=YMTDateUtil.diffSecond(new Date(Long.valueOf(livedto.getEndTime())),  YMTDateUtil.getDate( dblive.getEndTime(), YMTDateUtil.YMDHMSS));
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setLatitude("31.2929");
			livedto.setLongitude("100.4335");
			livedto.setLiveAddress("live地址");
			livedto.setLiveCover("http://img.ymatou.com/app/flag/circle/America.png");
			livedto.setLiveTitle("修改直播标题666666"+TestDataManager.getRandomNum(10));
			livedto.setShoppingAddress("ShoppingAddress");
			livedto.setPreVideoHeight(100);
			livedto.setPreVideoLength(1500);
			livedto.setPreVideoPic("http://img.ymatou.com/app/flag/circle/France.png");
			livedto.setPreVideoWidth(200);
			livedto.setPreVideoUrl("http://www.ymatou.com/PreVideoUrl");
			livedto.setSellerName("autotestsellername");
			livedto.setStopReason("结束");
			livedto.setLivePush(1);
			livedto.setPutawayCount(100);
			livedto.setLiveProductNum(200);
			livedto.setLiveDesc("mylivedesc");
			livedto.setLiveStatus(11);
			livedto.setAction(-1);
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			
			ModifySellerliveCall.setData(ModifySellerliveBean);
			String head="accesstoken="+cstoken;
			Logger.debug("ymt-pars:"+ head);
			ModifySellerliveCall.addHeader("ymt-pars", head);ModifySellerliveCall.callService();
//			Logger.verifyEquals("{}",ModifySellerliveCall.getJsonObject().toString(), "验证返回");
			 Logger.verifyEquals("400", ModifySellerliveCall.getString("code"), "验证Code");
			 Logger.verifyEquals("客服不能编辑直播", ModifySellerliveCall.getString("msg"), "验证msg");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_ModifySellerLive_023() {
		Logger.start(true, "修改LiveInherit成功");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomShop2cnCallService.initCreatesellerliveBean();
			LiveRoom livedto = LiveRoomShop2cnCallService.CreateSellerLive(initcreatebean,sellerId);
			LiveRoom dblive =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改前数据："+FormatUtil.beanToGSONString(dblive));
			livedto.setLiveInherit(true);
			livedto.setStartTime(YMTDateUtil.getTimeBySecond(5*60).toString());
			livedto.setEndTime(YMTDateUtil.getTimeBySecond(100*60).toString());
			ModifySellerliveBean.setLiveDto(livedto);
			ModifySellerliveCall.addHeader("ymt-pars", "accesstoken="+token);
			ModifySellerliveBean.setRequestId(TestDataManager.getRandomUUID().toString());
			ModifySellerliveCall.setData(ModifySellerliveBean);
			ModifySellerliveCall.callService();
			Logger.verifyEquals("{}",ModifySellerliveCall.getJsonObject().toString(), "验证返回");
			 Logger.comment("数据库验证");
			LiveRoom dblive2 =liveRoomShop2nWapper.selectLiveRoomById(livedto.getId());
			Logger.debug("修改后数据："+FormatUtil.beanToGSONString(dblive2));
			if(livedto.getLiveInherit()!=null) {
				Logger.verifyEquals(livedto.getLiveInherit(), dblive.getLiveInherit(), "验证LiveInherit");
			}
			// Logger.verifyIsContains("直播名称长度需在", ModifySellerliveCall.getString("Msg"), "验证Msg");
			 //直播名称长度需在4-18个汉字
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}